Jx.categorize('event.listener.dom.load', {

	$extend: 'Jx.event.Listener',
	
	$helpers: {
		
		'Event': 'Jx.platform.browser.lib.Event'
		
	},

	onInitialize: function(){

		this.$super(arguments);

		var o = this.dispatcher.observable,
		
			Event = this.$Event,

			dom = o.node;
			
		if (Event.isSupported(dom, 'readystatechange') && 'readyState' in dom){
			
			this.type('readystatechange');
			
		} else if (Event.isSupported(dom, 'load')){
			
			this.type('load');
			
		}

	},

	createWrapHandler: function(){

		var wrappedFn = this.$super(arguments);

		return this.type() == 'readystatechange' ?

			this.createStateChangeHandler(wrappedFn)

			:

			wrappedFn;

	},

	createStateChangeHandler: function(innerFn){

		function StateChangeEventHandler(listener, event){

			if (event.target().node().readyState == 'complete'){

				innerFn(listener, event);

			}

		}

		return StateChangeEventHandler;


	}

});
